﻿using Cemit.PolyProto;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cemit.NetFramework.Logger;
using Debug = Cemit.NetFramework.Logger.Debug;

namespace Cemit.NetFramework.Demo.PureFrameSync
{
    internal class OperationFrameMaster
    {
        Queue<F> queue = new Queue<F>();
        int i = 0;

        public int Remain => queue.Count;

        public void AddFrame(F frame)
        {
            if (frame.Index != i)
            {
                Debug.Log(
                    $"帧序号与应得到的序号不同！remove:{frame.Index} local:{i}");
            }
            i++;
            queue.Enqueue(frame);
        }

        public int ReadFrame(out IEnumerable<string> operationFrame)
        {
            var frame = queue.Dequeue();
            operationFrame = frame.Operation;
            return frame.Index;
        }
    }
}